package com.evaluationSystem.entity.vo;

import lombok.Data;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Data
public class AnalyseDetailVo {
    private String assessedId;
    private String assessedName;
    private List<AppraiserUser> appraiserUser;

    private static final Pattern PATTERN = Pattern.compile("\\d+");

    @Data
    public static class AppraiserUser {
        private String appraiserId;
        private String appraiserName;
        private Integer appraiseTiesId;
        private String appraiseTies;
        private String userScore;

        public void setAppraiseTiesIdFromAppraiseTies() {
            if (appraiseTiesId == null && appraiseTies != null) {
                Matcher matcher = PATTERN.matcher(appraiseTies);
                if (matcher.find()) {
                    appraiseTiesId = Integer.parseInt(matcher.group());
                }
            }
        }
    }
}
